/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.flexengine.language;

import java.io.Serializable;
import java.util.HashMap;

/**
 * @author Luann R. Athayde
 * @version 1.0
 * @since 1.0
 */
public class Language implements Serializable {

    private String                  name;
    private final HashMap<Integer,String> dictionary;

    public Language(String name, HashMap<Integer, String> dictionary) {
        this.name = name;
        this.dictionary = dictionary;
    }
    
    public Language() {
        this.name = "Default";
        this.dictionary = new HashMap<>();
    }
    
    public String getValue(int macro) {
        return dictionary.get(macro);
    }
    public int getMacro(String value) {
        String tmp;
        for(int i : dictionary.keySet() ) {
            tmp = dictionary.get(i);
            if( tmp.equals(value) ) {
                return i;
            }
        }
        return -1;
    }
    public Integer[] getMacros() {
        Object tmp[] = dictionary.keySet().toArray();
        Integer macros[] = new Integer[tmp.length];
        for(int i=0;i<tmp.length;i++) {
            macros[i] = (Integer)tmp[i];
        }
        return macros;
    }
    public boolean contaisMacro(int macro) {
        return dictionary.containsKey(macro);
    }
    public boolean contaisValue(String value) {
        return dictionary.containsValue(value);
    }
    
    protected void clear() {
        dictionary.clear();
    }
    protected void put(int macro, String value) {
        dictionary.put(macro, value);
    }

    public String getName() {
        return name;
    }

    protected void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return name;
    }
    
}
